package com.youlai.boot.system.controller;

import com.youlai.boot.system.service.LpsOrderFsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.youlai.boot.system.model.form.LpsOrderFsForm;
import com.youlai.boot.system.model.query.LpsOrderFsQuery;
import com.youlai.boot.system.model.vo.LpsOrderFsVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.youlai.boot.common.result.PageResult;
import com.youlai.boot.common.result.Result;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;

/**
 * 莱普森扶手前端控制层
 *
 * @author youlaitech
 * @since 2025-08-18 10:16
 */
@Tag(name = "莱普森扶手接口")
@RestController
@RequestMapping("/api/v1/lpsOrderFss")
@RequiredArgsConstructor
public class LpsOrderFsController  {

    private final LpsOrderFsService lpsOrderFsService;

    @Operation(summary = "莱普森扶手分页列表")
    @GetMapping("/page")
    @PreAuthorize("@ss.hasPerm('system:lpsOrderFs:query')")
    public PageResult<LpsOrderFsVO> getLpsOrderFsPage(LpsOrderFsQuery queryParams ) {
        IPage<LpsOrderFsVO> result = lpsOrderFsService.getLpsOrderFsPage(queryParams);
        return PageResult.success(result);
    }

    @Operation(summary = "新增莱普森扶手")
    @PostMapping
    @PreAuthorize("@ss.hasPerm('system:lpsOrderFs:add')")
    public Result<Void> saveLpsOrderFs(@RequestBody @Valid LpsOrderFsForm formData ) {
        boolean result = lpsOrderFsService.saveLpsOrderFs(formData);
        return Result.judge(result);
    }

    @Operation(summary = "获取莱普森扶手表单数据")
    @GetMapping("/{id}/form")
    @PreAuthorize("@ss.hasPerm('system:lpsOrderFs:edit')")
    public Result<LpsOrderFsForm> getLpsOrderFsForm(
        @Parameter(description = "莱普森扶手ID") @PathVariable Long id
    ) {
        LpsOrderFsForm formData = lpsOrderFsService.getLpsOrderFsFormData(id);
        return Result.success(formData);
    }

    @Operation(summary = "修改莱普森扶手")
    @PutMapping(value = "/{id}")
    @PreAuthorize("@ss.hasPerm('system:lpsOrderFs:edit')")
    public Result<Void> updateLpsOrderFs(
            @Parameter(description = "莱普森扶手ID") @PathVariable Long id,
            @RequestBody @Validated LpsOrderFsForm formData
    ) {
        boolean result = lpsOrderFsService.updateLpsOrderFs(id, formData);
        return Result.judge(result);
    }

    @Operation(summary = "删除莱普森扶手")
    @DeleteMapping("/{ids}")
    @PreAuthorize("@ss.hasPerm('system:lpsOrderFs:delete')")
    public Result<Void> deleteLpsOrderFss(
        @Parameter(description = "莱普森扶手ID，多个以英文逗号(,)分割") @PathVariable String ids
    ) {
        boolean result = lpsOrderFsService.deleteLpsOrderFss(ids);
        return Result.judge(result);
    }
}
